home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3323 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.8 KB

  1. Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
  2. From: Dan Pop <danpop@mail.cern.ch>
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c,comp.lang.modula3,comp.lang.modula2,comp.lang.eiffel
  4. Subject: Re: Hungarian notation
  5. Date: Tue, 23 Jan 1996 12:43:24 +0100
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <9601231143.AA21138@dxmint.cern.ch>
  8. References: <30C40F77.53B5@swsbbs.com> <4d2ok0$69s@beach.and.nl> <4dtv3gINNo9u@keats.ugrad.cs.ubc.ca> <SPENCER.96Jan22113215@zorgon.ERA.COM> <4e1nd8$hv0@solutions.solon.com>
  9. X-NNTP-Posting-Host: hpl3sn03.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11. X-Mail2News-Path: dxmint.cern.ch!hpl3sn03.cern.ch
  12.  
  13. seebs@solutions.solon.com (Peter Seebach) writes:
  14.  
  15. >In article <SPENCER.96Jan22113215@zorgon.ERA.COM>,
  16. >Spencer Allain <spencer@ERA.COM> wrote:
  17. >>It is incorrect to say that a 'char' (of size 1 byte on many systems)
  18. >>and an 'int' (of size 4 bytes on many systems) is structurally
  19. >>equivalent, yet I must be able to compile this without errors:
  20. >>(warnings are _not_ errors -- though I get none compiling this anyway)
  21. >
  22. >>   char a;
  23. >>   int b;
  24. >>   int main()
  25. >>   {
  26. >>     b = -154267 ;
  27. >>     a = b ;
  28. >>     return 0 ;
  29. >>   }
  30. >
  31. >No warnings, perhaps, but undefined behavior unless CHAR_MIN is
  32. >less than or equal to -154267.
  33.  
  34. Nope.  The behaviour is implementation-defined.  ANSI classic 3.2.1.2:
  35.  
  36.     When an integer is demoted to a signed integer with smaller size, or an
  37.     unsigned integer is converted to its corresponding signed integer, if
  38.     the value cannot be represented the result is implementation-defined.
  39.  
  40. If char happens to be unsigned, the behaviour is well defined (but the
  41. "signedness" of char itself is implementation-defined :-)
  42.  
  43. Dan
  44. -- 
  45. Dan Pop
  46. CERN, CN Division
  47. Email: danpop@mail.cern.ch 
  48. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  49.